package org.bee.enums;

import org.bee.annotation.EnumsDict;

/**
 * 返回码定义
 * 规定:
 * #200表示成功 999表示失败 403权限错误
 * #1001～1999 区间表示参数错误
 * #2001～2999 区间表示用户错误
 * #3001～3999 区间表示接口异常
 */
@EnumsDict(value = "resultCode", desc = "状态码")
public enum ResultCode implements IEnum{
    /** 成功 */
    SUCCESS("200", "成功"),
    /** 权限错误 */
    NO_PERMISSION("403", "没有权限"),
    /** 默认失败 */
    COMMON_FAIL("999", "失败"),

    /** 参数错误：1000～1999 */
    PARAM_NOT_VALID("1001", "传参校验失败"),
    PARAM_CONFLICT("1002","参数转换错误"),
    PARAM_NOT_COMPLETE("1003","参数缺失"),

    /** 用户错误 */
    USER_NOT_LOGIN("2001", "用户未登录"),
    USER_CREDENTIALS_ERROR("2002", "用户名或密码错误"),
    USER_ACCOUNT_FREEZE("2003", "账号被冻结"),
    USER_ACCOUNT_ERROR("2004", "账号异常"),
    USER_ACCOUNT_ALREADY_EXIST("2005", "账号已存在"),
    /** token错误*/
    TOKEN_ERROR("2006","令牌无效,请重新登录"),
    /** 内部调用密钥错误 */
    INTERNAL_TOKEN_ERROR("2007","内部调用密钥错误"),

    /** 业务错误*/
    DATA_REPEAT("3000","数据重复"),
    DATA_IS_USED("3001","数据已被使用"),
    DATA_NULL("3002","数据为空"),
    TOO_MANY_REQUEST("3003","请求过于频繁"),
    STATUS_ERROR("3004","状态异常"),
    TO_JSON_ERROR("3005","json序列化失败"),
    EXCEL_IMPORT_ERROR("3006","excel导入异常"),
    /** 文件错误 */
    FILE_UPLOAD_ERROR("4001","文件上传异常"),
    FILE_DELETE_ERROR("4002","文件删除异常"),
    FILE_NOT_SUPPORT_ERROR("4003","文件类型不支持"),
    FOLDER_ALREADY_EXIST("4004","文件夹已存在"),
    FOLDER_CREATE_ERROR("4005","文件夹创建失败"),
    FOLDER_DELETE_ERROR("4006","文件夹删除失败"),
    FOLDER_NOT_EXIST("4007","文件夹不存在"),
    /** 代码生成错误*/
    TEMPLATE_NOT_EXIST_OR_ERROR("5001","模板不存在/异常"),
    DB_CONNECT_FAIL("5002","数据库连接失败"),
    FILE_GEN_ERROR("5003","生成失败"),

    /**
     * 批处理异常
     */
    BATCH_RUN_ERROR("6001","批处理执行异常"),
    BATCH_CRON_PARSER_ERROR("6002","cron表达式解析异常");


    private String code;
    private String desc;

    ResultCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }
}
